package com.tuo51.childcare.controller;


import com.tuo51.childcare.service.BizStoreItemService;
import com.tuo51.foudation.model.MemVerificationCache;
import com.tuo51.foudation.model.StatusResponse;
import com.tuo51.foudation.query.base.PagerQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;


@RequestMapping("/papi/childcare")
@RestController
@Api(value = "/papi/childcare", tags = "家长服务号 - 内容推荐")
public class PAPIChildCareController {

    @Autowired
    BizStoreItemService storeItemService;

    @Autowired
    MemVerificationCache cache;

    @RequestMapping(value = "/item_by_tag", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取关联对象", notes = "混合参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "分页下标"),
            @ApiImplicitParam(name = "pageSize", value = "页容量")
    })
    public StatusResponse getItemByTag(HttpServletRequest req,
                                       HttpServletResponse resp,
                                       String objectId,
                                       Integer objectType,
                                       Integer month,
                                       @RequestHeader(value = "ticket", required = false) String ticket,
                                       PagerQuery pagerQuery) {
        //先取此用户基本信息
        String uid = cache.getStaffId(ticket);

        //获取对应对象的tags
        return StatusResponse.success(storeItemService.getStoreItemByObjects(Arrays.asList(objectId), objectType, month));
    }
}
